//
//  UIColor+YMAdditions.swift
//  YMToolKit
//
//  Created by YDWY on 2017/4/20.
//  Copyright © 2017年 YDWY. All rights reserved.
//

import Foundation
import UIKit


extension UIColor {

    

    //16进制颜色
    class func ym_colorWihtHex(hex : Int32) -> UIColor{
    
        let r = (hex & 0xff0000) >> 16
        let g = (hex & 0x00ff00) >> 8
        let b = hex & 0x0000ff

        return self.ym_colorWithRGB(r: r, g: g, b: b)
    }
    
    //随机色
    class func ym_randomColor() -> UIColor{
    
        return self.ym_colorWithRGB(r: Int32(Int(Int8(arc4random_uniform(256)))), g:  Int32(Int8(arc4random_uniform(256))), b:  Int32(Int8(arc4random_uniform(256))))
    }
    
    // 三基色
    class func ym_colorWithRGB(r : Int32, g : Int32 ,b : Int32) -> UIColor{
    
        return UIColor(red: CGFloat(r) / CGFloat(255.0), green: CGFloat(g) / CGFloat(255.0), blue:  CGFloat(b) / CGFloat(255.0), alpha: 1.0)
        
    }
    
}
